
import { OpenAI } from  "openai";
import dotenv from "dotenv"

dotenv.config()

const client =new OpenAI({
  //process 是node里面的进程对象
  apiKey: process.env.OPENAI_API_KEY, 
  baseURL: process.env.OPENAI_BASE_URL
})


const getComleteion = async (prompt, model = "gpt-3.5-turbo") => {
  const messages = [{
      role: "user",
      content: prompt,
  }];

  const response = await client.chat.completions.create({
      model: model,
      messages: messages,
      temperature: 0.1,
  })

  // return {
  //     name: "电影名称", // 替换为实际的电影名称
  //     某种物质: "9.0" // 替换为实际的评分或其他物质
  // };

  return response.choices[0].message.content;
};



export {
  getComleteion
}

